using System;
using System.Collections;
using System.Collections.Specialized;

namespace UNLV.IAP.WebControls
{

	/// <summary>
	/// Strongly-typed collection of SqlWhereBuilderOperator objects
	/// </summary>
	[Serializable]
	public class SqlWhereBuilderOperatorsCollection : CollectionBase  
	{

		private string _id;

		/// <summary>
		/// Unique identifier for this OperatorsCollection
		/// </summary>
		public string Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public SqlWhereBuilderOperatorsCollection(string id) : base()
		{
			this.Id = id;
		}

		public SqlWhereBuilderOperatorsCollection() : base()
		{}

		public SqlWhereBuilderOperator this[ int index ]  
		{
			get  
			{
				return( (SqlWhereBuilderOperator) List[index] );
			}
			set  
			{
				List[index] = value;
			}
		}

		public int Add( SqlWhereBuilderOperator value )  
		{
			return( List.Add( value ) );
		}

		public int IndexOf( SqlWhereBuilderOperator value )  
		{
			return( List.IndexOf( value ) );
		}

		public void Insert( int index, SqlWhereBuilderOperator value )  
		{
			List.Insert( index, value );
		}

		public void Remove( SqlWhereBuilderOperator value )  
		{
			List.Remove( value );
		}

		public bool Contains( SqlWhereBuilderOperator value )  
		{
			// If value is not of type Int16, this will return false.
			return( List.Contains( value ) );
		}

		protected override void OnInsert( int index, Object value )  
		{
			if ( value.GetType() != Type.GetType("UNLV.IAP.WebControls.SqlWhereBuilderOperator") )
				throw new ArgumentException( "value must be of type SqlWhereBuilderOperator.", "value" );
		}

		protected override void OnRemove( int index, Object value )  
		{
			if ( value.GetType() != Type.GetType("UNLV.IAP.WebControls.SqlWhereBuilderOperator") )
				throw new ArgumentException( "value must be of type SqlWhereBuilderOperator.", "value" );
		}

		protected override void OnSet( int index, Object oldValue, Object newValue )  
		{
			if ( newValue.GetType() != Type.GetType("UNLV.IAP.WebControls.SqlWhereBuilderOperator") )
				throw new ArgumentException( "newValue must be of type SqlWhereBuilderOperator.", "newValue" );
		}

		protected override void OnValidate( Object value )  
		{
			if ( value.GetType() != Type.GetType("UNLV.IAP.WebControls.SqlWhereBuilderOperator") )
				throw new ArgumentException( "value must be of type SqlWhereBuilderOperator." );
		}

	}
}
